<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
</head>

<body style="color:#333;padding:3px;" class="x_sorll">
<!-- 标题 -->
<div class="page-heade">
    <h2 class="title_color text-center">销售费用核销面单-预览</h2>
</div>
<!-- 标题 -->
<div>
    <div class="form-inline">
        <table class="table table-bordered bud_hei text-center" style="margin-top:0">
            <tr>
                <td style="min-width: 140px;width: 140px;">申请人</td>
                <td class="text-left"><a href="javascript:;">{$basic.cuser_title}</a></td>
                <td style="min-width: 140px;width: 140px;">所属部门/职位</td>
                <td class="text-left"></td>
                <td style="min-width: 140px;width: 140px;">提交时间</td>
                <td class="text-left">{:date('Y-m-d H:i',$basic.ctime)}</td>
            </tr>
            <tr>
                <td style="min-width: 140px;width: 140px;">经销商名称</td>
                <td colspan="5" class="text-left">{$basic.jxs_title}</td>
            </tr>
            <tr>
                <td colspan="6" class="text-left">
                    <p class="font-bold colorRed">温馨提示：请在发票粘贴联上注明此申请单编号{$basic.sn}<a href="javascript:;">点击查看图例</a></p>
                    <p class="font-bold colorRed">并邮寄至：签收。(如邮寄地址未显示，请联系相关人员进行邮寄地址添加)</p>
                </td>
            </tr>
        </table>
        <table class="table table-bordered bud_hei text-center">
            <tr class="info">
                <th class="text-center" rowspan="2">序号</th>
                <th class="text-center" rowspan="2">原申请人</th>
                <th class="text-center" rowspan="2">原申请文件</th>
                <th class="text-center" rowspan="2">明细编号</th>
                <th class="text-center" rowspan="2">核查结果</th>
                <th class="text-center" rowspan="2">{$basic.area_title}</th>
                <th class="text-center" rowspan="2">{$basic.area_title2}</th>
                <th class="text-center" rowspan="2">品牌</th>
                <th class="text-center" rowspan="2">三级费用科目</th>
                <th class="text-center" colspan="3">实际投入</th>
                <th class="text-center" colspan="8">本次申请核销</th>
                <th class="text-center" rowspan="2">活动开始日期</th>
                <th class="text-center" rowspan="2">支付方式</th>
                <th class="text-center" rowspan="2">备注</th>
            </tr>
            <tr class="info">
                <th class="text-center">实际投入金额</th>
                <th class="text-center">已核销金额</th>
                <th class="text-center">未核销金额</th>
                <th class="text-center">未税核销金额</th>
                <th class="text-center">
                    有无发票
                </th>
                <th class="text-center">
                    发票号
                </th>
                <th class="text-center">
                    是否增值税<br>(可抵扣)
                </th>
                <th class="text-center">
                    税率
                </th>
                <th class="text-center">税金</th>
                <th class="text-center">含税核销金额</th>
                <th class="text-center">实际投入金额</th>
            </tr>
            {volist name="data" id="row" key="k"}
            <tr>
                <td>{$k}</td>
                <td>{$row.ti_cuser}</td>
                <td><a href="{:url('view',['id'=>$row.ti_id])}">{$row.ti_sn}</a></td>
                <td>{$row.ti_sn}_{$row.list_sn}</td>
                <td>无</td>
                <td>{if isset($row.net_title)}<a href="javascript:;">{$row.net_title}</a>{else}无{/if}</td>
                <td>{if isset($row.system_title)}<a href="javascript:;">{$row.system_title}</a>{else}无{/if}</td>
                <td>{$row.product_name}</td>
                <td>{:db('cg_feiyongkemu3')->where('id',$row.feetype)->value('title')}</td>
                <td class="ObjectNum">{$row.fb_shijiweishui}</td>
                <td class="ObjectNum">{$row.hx_yihexiao}</td>
                <td class="ObjectNum">{$row.fb_shijiweishui-$row.hx_yihexiao}</td>
                <td class="ObjectNum">{$row.weishuihexiaojine}</td>
                <td>{if $row.youwufapiao==1}有{else}无{/if}
                </td>
                <td>{$row.fapiaohao}</td>
                <td>{if $row.shizengzhishui==1}是{else}否{/if}
                </td>
                <td><span class="ObjectNum">{$row.shuilv}</span>%</td>
                <td class="ObjectNum">{$row.shuijin}</td>
                <td class="ObjectNum">{$row.hanshuihexiaojine}</td>
                <td class="ObjectNum">{$row.shijitourujine}</td>
                <td>{:empty($row.huodongkaishiriqi)?date('Y-m-d',$row.start):date('Y-m-d',$row.huodongkaishiriqi)}</td>
                <td>{$row.zhifufangshi}</td>
                <td>{$row.beizhu}</td>
            </tr>
            {/volist}
            <tfoot>
            <tr class="text-right">
                <td colspan="9" class="font-bold">合计</td>
                <td class="ObjectNum">{$sum_shijitourujine}</td>
                <td class="ObjectNum">{$sum_hx_yihexiao}</td>
                <td class="ObjectNum">{$sum_weihexiaojine}</td>
                <td class="ObjectNum">{$sum_weishuihexiaojine}</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td class="ObjectNum">{$sum_shuijin}</td>
                <td class="ObjectNum">{$sum_hanshuihexiaojine}</td>
                <td class="ObjectNum">{$sum_shijitourujine}</td>
                <td colspan="3"></td>
            </tr>
            </tfoot>
        </table>
        <table class="table-bordered table">
            <tr>
                <td class="text-center" style="min-width: 120px;width: 120px;min-height:50px;height: 50px; ">备注:</td>
                <td><textarea name="beizhu" id="beizhu" class="form-control" style="width: 60%;overflow: auto;">{$basic.beizhu}</textarea><span
                        style="vertical-align: bottom;">(500)</span></td>
            </tr>
            <tr>
                <td class="text-center" style="min-width: 120px;width: 120px">归档提醒</td>
                <td><input type="checkbox" name="guidangtixing" value="1">(温馨说明:若设置归档提醒，则该申请归档后系统会自动发送邮件及弹出框提醒您)</td>
            </tr>
        </table>
        <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            {if isset($attach)}
            <ul class="list-group">
                {volist name="attach" id="row"}
                <li class="list-group-item">
                    <a class="badge badge-primary removeIt" data-id="{$row.id}">移除</a>
                    <a href="{$row.path}" target="_blank">{$row.file_name}</a></li>
                {/volist}
            </ul>
            {/if}
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list"></div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach">
                <input type="hidden" name="remove" id="remove">
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>
        <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0">
            <input type="button" class="btn btn-success save" value="保存为草稿" id="save1">
            <input type="button" class="btn btn-primary save" value="保存并提交流程" id="save2">
        </div>
    </div>
</div>
{include file="Public/footer"}
<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/common.js"></script>
<script>
    $(function () {
        $('.save').on('click',function () {
            var beizhu = $('#beizhu').val()
            var guidangtixing = $('[name=guidangtixing]:checked').val();
            if(typeof guidangtixing=='undefined'){
                guidangtixing = 0
            }
            var hx_id = '{:request()->param("hx_id")}'

            var savetype = $(this).prop('id')
            $.post('{:url("hxpreview")}',
                {beizhu:beizhu,guidangtixing:guidangtixing,hx_id:hx_id,savetype:savetype},
                function (data) {
                    if(data.success){
                        swal({
                            title:data.msg,
                            type:'success'
                        },function () {
                            location.href='{:url("index")}'
                        })
                    }else
                        swal(data.msg, "", "error");
                },'json')
        })
    })
</script>
</body>
<!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script>
    // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });

        //关闭
        $('#renyuan').on('click','.ren .close',function () {
            $(this).closest('.ren').remove()
        })

        //保存为模板
        $('#save3').on('click',function () {
            var title = $('input[name=title]').val();
            var brief = $('.summernote').code();
            $.post('{:url("Titemplate/add")}',
                {title:title,brief:brief,ispublic:0},
                function (data) {
                    if(data.success){
                        swal({
                            title:data.msg,
                            type:'success'
                        },function () {
                            swal('保存成功', "", "error");
                        })
                    }else
                        swal(data.msg, "", "error");

                },'json')
        })

        //模板覆盖
        $('select.templ').on('change',function () {
            var _this = this

            var id = $(this).val()
            swal({
                title: "确定用模板替换当前内容吗",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定",
                closeOnConfirm: false
            }, function (isConfirm) {
                if(isConfirm){
                    $.ajax({
                        'type':'post',
                        'url':'{:url("Titemplate/find")}?id='+id,
                        'dataType':'json',
                        'success':function (data) {
                            if(data.success){
                                $('#title').val(data.title)
                                $('.summernote').code(data.brief)
                                swal.close()
                            }else
                                swal(data.msg, "", "error");
                        }
                    })

                }

            })
        })
    });
</script>
</html>